/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model.information;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Observable;
import java.util.ArrayList;

/**
 * A class that represents a meal in the diet plan.
 * @author Tobias Møller Kjærsgaard
 * @author Hjalte Blichfeldt Flyger
 * @author Gitte Simonsen
 * @author Claus Lund
 */
public class Meal extends Observable implements Serializable {

    //////// Fields for class Meal ////////

    private String name;
    private ArrayList<Food> food;
    private int prot;
    private Calendar date;

    //////// Constructor that takes params ////////

    public Meal(String name) {
        this.name = name;
        food = new ArrayList<Food>();
        this.date = Calendar.getInstance();
    }

    //////// Setters and getters ////////

    public ArrayList<Food> getFood() {
        return food;
    }

    public void setFood(ArrayList<Food> food) {
        this.food = food;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    //////// Other methods ////////

    public void addFood(Food fo) {
        food.add(fo);
    }

    public void removeFood(Food fo) {
        food.remove(fo);
    }

    public int calcProt(int m, Food fo) {
        int eatenProt = ((fo.getProt()/100)*m);
        return eatenProt;
    }

    public int calcCar(int m, Food fo) {
        int eatenCar = ((fo.getCar()/100)*m);
        return eatenCar;
    }

    public int calcFat(int m, Food fo) {
        int eatenFat = ((fo.getFat()/100)*m);
        return eatenFat;
    }

    public int calcKcal(int m, Food fo) {
        int eatenKcal = ((fo.getKcal()/100)*m);
        return eatenKcal;
    }

    public int calcTotalProt() {
        int value = 0;
        for (Food f: food) {
            value += f.getProt();
        }
        return value;
    }

    public int calcTotalCar() {
        int value = 0;
        for (Food f: food) {
            value += f.getCar();
        }
        return value;
    }

    public int calcTotalFat() {
        int value = 0;
        for (Food f: food) {
            value += f.getFat();
        }
        return value;
    }

    public int calcTotalKcal() {
        int value = 0;
        for (Food f: food) {
            value += f.getKcal();
        }
        return value;
    }
   
}
